<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
</head>
<style>
    body{
        text-align: center;
    }
    input{
        width: 200px;
        height: 40px;
        font-size: 20px;
    }
    div{
        width: 600px;
        height: 60px;
        margin: auto;
    }
    p{
        font-size: 52px;
    }
</style>
<body>
    <div>
        <input type="checkbox" name="" id="apple"><span>苹果-</span><span>7</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>梨-</span><span>10</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>榴莲-</span><span>55</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>车厘子-</span><span>35</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>糖葫芦-</span><span>5</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>甘蔗-</span><span>15</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>芒果-</span><span>25</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>草莓-</span><span>20</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <div>
        <input type="checkbox" name="" id="putao"><span>葡萄-</span><span>15</span>
        <input type="number" name='num' value="1" min="0">
    </div>
    <p>总价：<span>0</span></p>
    <p><input type="checkbox" name="" id="all">全选</p>
</body>
<script>
    $(function () {
        $('div :checkbox,[name="num"]').change(function () {
            var total = 0
            $('div :checkbox').each(function () {
                if ($(this).prop('checked')) {
                    var price = $(this).next().next().html()
                    var num = $(this).next().next().next().val()
                    total += (price * num)
                }
            })
            $('span').last().html(total)
        })
        $('#all').change(function () {
            $('div :checkbox').prop('checked', $(this).prop('checked'))
            $('div :checkbox').change()
        })
    })
</script>

</html>